//
//  TouXiang.m
//  PokerPlus
//
//  Created by Lv Changye on 11-7-28.
//  Copyright 2011年 139me. All rights reserved.
//

#import "TouXiang.h"


@implementation TouXiang

+(TouXiang *)initWithName:(NSString *)name image:(UIImage *)img money:(int)money{
    TouXiang *button=[UIButton buttonWithType:UIButtonTypeCustom];
    button.frame=CGRectMake(0, 0, 40, 60);
    
    UILabel *nameLab=[[UILabel alloc]initWithFrame:CGRectMake(10,20, 0, 0)];
    nameLab.backgroundColor=[UIColor clearColor];
    nameLab.text=name;
    nameLab.alpha=0.0;
    nameLab.textAlignment=UITextAlignmentCenter;
    nameLab.textColor=[UIColor whiteColor];
    nameLab.font=[UIFont systemFontOfSize:0];
    [button addSubview:nameLab];
    
    
    UILabel *moneyLab=[[UILabel alloc]initWithFrame:CGRectMake(10, 40, 0, 0)];
    moneyLab.backgroundColor=[UIColor clearColor];
    moneyLab.text=[NSString stringWithFormat:@"$%d",money];
    moneyLab.textColor=[UIColor whiteColor];
    moneyLab.alpha=0.0;
    moneyLab.textAlignment=UITextAlignmentCenter;
    moneyLab.font=[UIFont systemFontOfSize:0];
    [button addSubview:moneyLab];
    
  
    UIImageView *image=[[UIImageView alloc]initWithFrame:CGRectMake(20, 30, 0, 0)];
    image.image=img;
    image.alpha=0.0;
    [button addSubview:image];
    
    
    [UIView beginAnimations:@"btn" context:nil];
    [UIView setAnimationDuration:0.45];
    nameLab.frame=CGRectMake(0, 0, 40, 10);
    nameLab.alpha=1.0;
    nameLab.font=[UIFont systemFontOfSize:10];
    moneyLab.frame=CGRectMake(0, 50, 40, 10);
    moneyLab.alpha=1.0;
    moneyLab.font=[UIFont systemFontOfSize:10];
    image.frame=CGRectMake(0, 10, 40, 40);
    image.alpha=1.0;
    
    [UIView commitAnimations];
    
    [nameLab release];
    [moneyLab release];
    [image release];
    return button;
    
}

@end
